package it.avantsoft.ls.gl.message;

import java.io.DataOutputStream;
import java.io.IOException;

public class HorizontalBalanceMessage extends GroupLeaderMessage {
    private int loadDifference;
    private String designedGroupLeaderId;


    public HorizontalBalanceMessage(DataOutputStream out, int loadDifference, String designedGroupLeaderId) {
        super(out);
        this.loadDifference = loadDifference;
        this.designedGroupLeaderId = designedGroupLeaderId;
    }

    public boolean send() {
        boolean sent = false;
        try {
            writeByte(HORIZONTAL_BALANCE);
            writeInt(loadDifference);
            writeUTF(designedGroupLeaderId);
            flush();
            sent = true;
        } catch (IOException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }
        return sent;
    }


    public String toString() {
        return "HorizontalBalanceMessage{" +
                "loadDifference=" + loadDifference +
                '}';
    }
}
